package cn.ffcs.share.dao;


import java.util.List;

import org.hibernate.Query;

import cn.ffcs.base.dao.BaseDAO;
import cn.ffcs.share.model.ShareReference;

/**
 * 
 * 共享资料DAO实现<br/> <table>
 * <tr>
 * <td>负责人/principal: </td>
 * <td colspan="2">pany</td>
 * <tr>
 * <td>修改记录/revision:</td>
 * <td colspan="2"></td>
 * </tr>
 * <tr>
 * <td>日期:</td>
 * <td>修改人:</td>
 * <td>修改说明:</td>
 * </tr>
 * <tr>
 * <td></td>
 * <td></td>
 * <td></td>
 * </tr>
 * </table>
 * @author pany
 * @version $Id$
 */
public class ShareReferenceDAO<D extends ShareReference> extends BaseDAO<D> implements IShareReferenceDAO<D>
{

    /**
     * 获取共享资料实体类
     * @param b
     * @return
     */
    public String getEntityName()
    {
        return new ShareReference().getClass().getName();
    }
    
    /**
     * 根据类型取定量数据
     * {@inheritDoc}
     */
    public List findShareReferenceByType(String dictType,String count){
        StringBuffer sbHql=new StringBuffer();
        sbHql.append("select b from Dict t ,DictType a,ShareReference b ");
        sbHql.append("where a.keyValue=:key_value and t.dictType=a.id ");
        sbHql.append("and b.end>sysdate " );
        sbHql.append("and t.id=b.referenceType and rownum<" + count+" order by b.begin desc");
        Query query=getSession().createQuery(sbHql.toString());
        query.setString("key_value",dictType);
        return query.list();
    }
    
    
}
